package org.example.gradle.base.config.mq.cdtc;

import gradle.rabbit.common.constants.RabbitTemplateConstant;
import jakarta.annotation.Resource;
import gradle.rabbit.common.mq.cdtc.CdtcDockingExchangeConstants;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.context.annotation.Configuration;

/**
 * 交换机
 */
@Configuration
public class CdtcExchangeMqConfiguration {

    /**
     * 注入RabbitAdmin
     */
    @Resource(name = RabbitTemplateConstant.PRIMARY_RABBIT_TEMPLATE)
    private RabbitAdmin rabbitAdmin;

    /**
     * 创建 交换机
     */
    public FanoutExchange cdtcReturnCrossBorderIbExchange() {
        FanoutExchange fanoutExchange = new FanoutExchange(CdtcDockingExchangeConstants.CDTC_RETURN_CROSS_BORDER_IB_EXCHANGE, true, false);
        rabbitAdmin.declareExchange(fanoutExchange);
        return fanoutExchange;
    }
}
